/**
 * @Author: XXHH
 * @CreateTime: 2024-12-23
 */
public class Demo28 {
    public static void main(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread t1 = new Thread(()->{
            System.out.println("t1 wait 等待之前");
            try {
                synchronized (object) {
                    object.wait();
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("t1 wait 等待之后");
        });
        Thread t2 = new Thread(()->{
            System.out.println("t2 notify之前");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (object){
                object.notify();
            }
            System.out.println("t2 notify之后");
        });
        t1.start();
        t2.start();
    }
}
